package main

import "fmt"

// PublishInfo ...
type PublishInfo struct {
	Org         string
	MSPID       string
	Peers       NodeInfo
	Orderers    NodeInfo
	MSPCert     []byte
	AnchorPeers []string
}

// NodeInfo ...
type NodeInfo struct {
	Cert  []byte
	Nodes []*RemoteNode
}

// RemoteNode ...
type RemoteNode struct {
	ID       string
	Address  string
	Override string
}

func main() {
	var nodes []*RemoteNode
	nodes = append(nodes, &RemoteNode{
		ID:       "orderer-0-baas2",
		Address:  "192.168.9.159",
		Override: "orderer-0-baas2",
	})
	nodes = append(nodes, &RemoteNode{
		ID:       "orderer-0-baas4",
		Address:  "192.168.9.159",
		Override: "orderer-0-baas4",
	})
	nodes = append(nodes, &RemoteNode{
		ID:       "orderer-1-baas4",
		Address:  "192.168.9.159",
		Override: "orderer-1-baas4",
	})
	orgInfo := &PublishInfo{
		Peers:    NodeInfo{
			Nodes: nodes,
		},
		Orderers: NodeInfo{
			Nodes: nodes,
		},
	}

	for index, orderer := range orgInfo.Orderers.Nodes {
		if orderer.ID == "orderer-0-baas2" {
			orgInfo.Orderers.Nodes = append(
				orgInfo.Orderers.Nodes[:index],
				orgInfo.Orderers.Nodes[index + 1:]...)
		}
	}

	for _, orderer := range orgInfo.Orderers.Nodes {
		fmt.Println(orderer.ID)
	}
}
